package com.xx.job.controller.system;


import com.xx.job.common.Result;
import com.xx.job.controller.dto.PageDTO;
import com.xx.job.entity.system.SysConfig;
import com.xx.job.service.system.SysConfigService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.stereotype.Controller;
import com.xx.job.controller.base.BaseController;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author liangcy
 * @since 2021-01-14
 */
@RestController
@RequestMapping("/api/v1")
public class SysConfigController extends BaseController {

    @Autowired
    private SysConfigService sysConfigService;

    @RequestMapping("/configList")
    public Result configList(PageDTO pageDTO, SysConfig sysConfig){
        return Result.success(sysConfigService.selectPage(pageDTO,sysConfig));
    }

    @PostMapping("/config")
    public Result addConfig(@RequestBody SysConfig sysConfig){
        return Result.success(sysConfigService.add(sysConfig));
    }

    @DeleteMapping("/config/{id}")
    public Result deleteConfig(@PathVariable Long id){
        return Result.success(sysConfigService.delete(id));
    }

    @PutMapping("/config")
    public Result updateConfig(@RequestBody SysConfig sysConfig){
        return Result.success(sysConfigService.update(sysConfig));
    }

    @GetMapping("/config/{id}")
    public Result selectConfig(@PathVariable Long id){
        return Result.success(sysConfigService.select(id));
    }
}

